package com.zrwl.poscloud.core.restapi.message;

import com.zrwl.poscloud.commons.utils.FileUtils;
import com.zrwl.poscloud.xo.service.EmailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;


@RestController
@RequestMapping("/email")
@Slf4j
public class EmailRestApi {

    @Autowired
    private EmailService emailService;

    //最简单邮件
    @GetMapping("/sendSimpleMail")
    public void sendEmail() {
        emailService.sendEmail(
                "1273692478@qq.com",
                "2771768682@qq.com",
                "1",
                "123");
    }

    //带页面的邮件
    //localhost:8611/email/sendHtmlMail
    @GetMapping("/sendHtmlMail")
    public void sendHtmlMail() throws MessagingException {
        emailService.sendHtmlMail("2771768682@qq.com", "helloWorld");

    }

    //localhost:8611/email/chooseFile
    @GetMapping("/chooseFile")
    public void chooseFile() throws MessagingException {
        FileUtils.getFilePath();
    }

    //localhost:8611/email/sendMailWithFile
    @GetMapping("/sendMailWithFile")
    public void sendMailWithFile() throws MessagingException{
        emailService.sendMailWithFile();
    }


}

